package com.qidian.mes.dv.controller;

import com.qidian.mes.dv.service.SubjectService;
import com.qidian.mes.pojo.dv.Subject;
import com.qidian.mes.util.pojo.MESResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 迄氺(甄闯)
 * @Company 空白
 * @Time 2023/10/28 14:25
 * @Description
 */
@RestController
@RequestMapping("/subject")
@CrossOrigin
public class SubjectController {

    @Autowired
    private SubjectService subjectService;

    @RequestMapping("/get")
    public MESResult selectBySubjectId(Long subjectId){
        return subjectService.selectBySubject(subjectId);
    }
    @PostMapping("/save")
    public MESResult save(@RequestBody Subject subject){
        return subjectService.save(subject);
    }

    @GetMapping("/list")
    public MESResult list(Subject subject,@RequestParam(defaultValue = "1") int page,@RequestParam(defaultValue = "10") int limit){
        return subjectService.queryByPage(subject,page,limit);

    }
    @PutMapping("/update")
    public MESResult update(@RequestBody Subject subject){
        return subjectService.update(subject);
    }

    @DeleteMapping("/deleteById")
    public MESResult deleteById( Long subjectId) {
        return subjectService.deleteById(subjectId);
    }
}
